home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d18
/
nrpas13.arc
/
LINMIN.DEM
< prev
next >
Wrap
Text File
|
1991-05-01
|
1KB
|
68 lines
PROGRAM d10r7(input,output);
(* driver for routine LINMIN *)
CONST
ndim=3;
pio2=1.5707963;
TYPE
glnp = ARRAY [1..ndim] OF real;
glndim = glnp;
glnarray = glnp;
VAR
ncom : integer;
pcom,xicom : glndim;
fret,sr2,x : real;
i,j : integer;
p,xi : glnp;
FUNCTION fnc(x : glnp) : real;
(* calling routine must define type
TYPE
glnp = ARRAY [1..np] OF real;
where np dimension of vector x. *)
VAR
i : integer;
f : real;
BEGIN
f := 0.0;
FOR i := 1 to 3 DO BEGIN
f := f+sqr(x[i]-1.0)
END;
fnc := f
END;
(*$I MODFILE.PAS *)
(*$I F1DIM.PAS *)
FUNCTION func(x: real): real;
BEGIN
func := f1dim(x)
END;
(*$I MNBRAK.PAS *)
(*$I BRENT.PAS *)
(*$I LINMIN.PAS *)
BEGIN
writeln;
writeln('Minimum of a 3-d quadratic centered');
writeln('at (1.0,1.0,1.0). Minimum is found');
writeln('along a series of radials.');
writeln;
writeln('x':9,'y':12,'z':12,'minimum':14);
FOR i := 0 to 10 DO BEGIN
x := pio2*i/10.0;
sr2 := sqrt(2.0);
xi[1] := sr2*cos(x);
xi[2] := sr2*sin(x);
xi[3] := 1.0;
p[1] := 0.0;
p[2] := 0.0;
p[3] := 0.0;
linmin(p,xi,ndim,fret);
FOR j := 1 to 3 DO write(p[j]:12:6);
writeln(fret:12:6)
END
END.